package gewu.suleju.dao.iml;

import gewu.suleju.model.pojo.HouseInfor;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

//        or min_rent_date = "月租"
//        or floor = "低楼层"
//        or elevator = "有"
//        or direction = "北"
//        or square_meter = 100
public interface IHouseInforOneDao extends JpaRepository<HouseInfor,Integer> {
    List<HouseInfor> findByRentPriceAndIsStatus(Integer rentPrice, Integer isStatus);

    List<HouseInfor> findByHouseTypeContainingAndIsStatus(String houseType, Integer isStatus);

    List<HouseInfor> findByCommunityContainingAndIsStatus(String community, Integer isStatus);

    List<HouseInfor> findByHouseAddressContainingAndIsStatus(String houseAddress, Integer isStatus);

    List<HouseInfor> findByRentTypeContainingAndIsStatus(String rentType, Integer isStatus);

    List<HouseInfor> findByPayTypeContainingAndIsStatus(String payType, Integer isStatus);

    List<HouseInfor> findByAreaContainingAndIsStatus(String area, Integer isStatus);

    List<HouseInfor> findByMinRentDateContainingAndIsStatus(String minRentDate, Integer isStatus);

    List<HouseInfor> findByFloorContainingAndIsStatus(String floor, Integer isStatus);

    List<HouseInfor> findByElevatorContainingAndIsStatus(String elevator, Integer isStatus);

    List<HouseInfor> findByDirectionContainingAndIsStatus(String direction, Integer isStatus);

    List<HouseInfor> findBySquareMeterAndIsStatus(Integer squareMeter, Integer isStatus);

    List<HouseInfor> findBySubwayContainingAndIsStatus(String subway, Integer isStatus);

    @Transactional
    @Query(value="select * from house_infor where rent_price between ?1 and ?2 and is_status = ?3",nativeQuery=true)
    List<HouseInfor> findBetween(Integer before, Integer after, Integer isStatus);

    @Transactional
    @Query(value="select * from house_infor where rent_price < ?1 and is_status = ?2",nativeQuery=true)
    List<HouseInfor> findUnder(Integer under, Integer isStatus);

    @Transactional
    @Query(value="select * from house_infor where rent_price > ?1 and is_status = ?2",nativeQuery=true)
    List<HouseInfor> findOn(Integer on, Integer isStatus);
}
